package com.situ.car.dao.Impl;

import com.situ.car.dao.IBrandDao;
import com.situ.car.pojo.entity.Brand;
import com.situ.car.util.JDBCUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

public class BrandDaoImpl implements IBrandDao {
    private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
    @Override
    public List<Brand> selectByBrand() {
        return template.query("select * from car_brand", new BeanPropertyRowMapper<>(Brand.class));
    }

    @Override
    public Brand selectByBrandName(Integer brandId) {
        return template.queryForObject("select * from car_brand where brand_id=?", new BeanPropertyRowMapper<>(Brand.class), brandId);
    }
}
